<?php

namespace app\server\model;

use Workerman\MySQL\Connection;

class Db
{

    public $db;

    // 存放实例
    private static $_instance = null;

    // 私有化构造方法、
    private function __construct(){
        $config = Config::get('db');
        $this->db = new Connection($config['host'], $config['port'], $config['user'], $config['password'], $config['db_name']);
    }

    // 私有化克隆方法
    private function __clone(){

    }

    // 公有化获取实例方法
    public static function instance(){
        if (!(self::$_instance instanceof self)){
            self::$_instance = new self();
        }
        return self::$_instance;
    }

}